package com.itcast.demo;

import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.util.Properties;

public class BeanUtils {
    private Properties prop=new Properties();

    public Object getBean(String name) throws Exception {
        InputStream in = BeanUtils.class.getClassLoader().getResourceAsStream("prop.properties");
        prop.load(in);
        String _clazz = prop.getProperty(name);
        Constructor cons = Class.forName(_clazz).getConstructor();
        Object obj = cons.newInstance();
        return obj;
    }
}
